import dayjs from 'dayjs'

export default class MinArticle {
    static insertObj ({name = null, content = null, files = null, user_id = null}) {
        if(name !== null && content !== null && files !== null && user_id !== null){
            return {
                name,
                content,
                files: JSON.stringify(files),
                update_time: dayjs().format('YYYY-MM-DD HH:MM:ss'),
                user_id
            }
        }else {
            return false
        }
    }

    static deleteObj ({id = null}) {
        if(id !== null){
            return {
                id
            }
        }else {
            return false
        }
    }

    static updateObj ({id = null, name = null, content = null, files = null, user_id = null}) {
        if(id !== null){
            return {
                id,
                name,
                content,
                files: JSON.stringify(files),
                update_time: dayjs().format('YYYY-MM-DD HH:MM:ss'),
                user_id
            }
        }else {
            return false
        }
    }
}